1 package uba.db.table.io;
2
3 import java.io.DataInput;
4 import java.io.IOException;
5 import java.util.Iterator;
6
7 import uba.db.column.Column;
8 import uba.db.column.io.ColumnReader;
9 import uba.db.table.Row;
10 import uba.db.table.Table;
11
12 /***
13 * @version $Revision: 1.2 $
14 */
15 public class RowReader {
16 private ColumnReader[] readers;
17 private Table table;
18
19 public RowReader(Table table, DataInput in) {
20 this.table = table;
21 readers = new ColumnReader[table.columns().size()];
22 Iterator iter = table.columns().iterator();
23
24 for (int i = 0; iter.hasNext(); i++) {
25 Column column = (Column) iter.next();
26 readers[i] = column.readerFor(in);
27 }
28
29 }
30
31 public Row read() throws IOException {
32 Object[] values = new Object[readers.length];
33 for (int i = 0; i < readers.length; i++) {
34
35 values[i] = readers[i].read();
36 }
37
38 return new Row(table, values);
39 }
40 }